export function isObject(params) {
  return Object.prototype.toString.call(params) === '[object Object]'
}

export function isArray(params) {
  return Object.prototype.toString.call(params) === '[object Array]'
}

export function getUrlParams(str, key) {
  if (!str) {
    return ''
  }
  const result = decodeURIComponent(str)
    .split('?')[1]
    .split('&')
    .reduce((prev, curr) => {
      const [key, value] = curr.split('=')
      if (prev[key]) {
        prev[key] = [value].concat(prev[key])
      } else {
        prev[key] = value
      }
      return prev
    }, {})
  return key ? result[key] : result
}
